package com.gm.wholesale.module.kind.model;

import android.util.ArrayMap;

import com.gm.commonlib.base.baseBean.BaseResp;
import com.gm.commonlib.base.baseBean.DataResp;
import com.gm.commonlib.base.baseView.IBaseView;
import com.gm.commonlib.network.BaseHttpObserver;
import com.gm.commonlib.network.HttpClient;
import com.gm.commonlib.network.HttpServicesHolder;
import com.gm.wholesale.module.kind.api.IKindApi;
import com.gm.wholesale.module.unit.api.IUnitApi;

import io.reactivex.Observable;

public class KindModel {

    //修改分类
    public static void updateKind(IBaseView iBaseView,
                                  long id, ArrayMap<String, Object> data,
                                  BaseHttpObserver<BaseResp> observer) {
        HttpClient.sendRequest(iBaseView, new HttpServicesHolder<IKindApi, BaseResp>() {
            @Override
            public Observable<BaseResp> getHttpObservable(IKindApi instance) {
                return instance.updateCategory(id, data);
            }
        }, observer);
    }

    //创建分类
    public static void createKind(IBaseView iBaseView,
                                  ArrayMap<String, Object> data,
                                  BaseHttpObserver<DataResp<Long>> observer) {
        HttpClient.sendRequest(iBaseView, new HttpServicesHolder<IKindApi, DataResp<Long>>() {
            @Override
            public Observable<DataResp<Long>> getHttpObservable(IKindApi instance) {
                return instance.createKind(data);
            }
        }, observer);
    }



    //删除分类
    public static void deleteKind(IBaseView iBaseView,
                                  long id,
                                  int version,
                                  BaseHttpObserver<BaseResp> observer) {
        HttpClient.sendRequest(iBaseView, new HttpServicesHolder<IKindApi, BaseResp>() {
            @Override
            public Observable<BaseResp> getHttpObservable(IKindApi instance) {
                return instance.deleteKind(id,version);
            }
        }, observer);
    }
}
